/*
 * @Author: quit
 * @Date: 2021-11-09 16:01:11
 * @LastEditTime: 2021-12-07 17:11:30
 * @Descripttion: cookie操作
 */
import Cookies from 'js-cookie'

const TokenKey = 'HRXY_admin_token' // Token 建

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// localStorage数据操作
// sessionStorage数据操作
export function getData(DateKey) {
  if (window.sessionStorage) {
    return JSON.parse(sessionStorage.getItem(DateKey))
  } else {
    console.log('当前浏览器不支持Storage,启用Cookies')
    return Cookies.get(DateKey)
  }
}

export function setData(key, value) {
  if (window.sessionStorage) {
    return sessionStorage.setItem(key, JSON.stringify(value))
  } else {
    console.log('当前浏览器不支持Storage,启用Cookies')
    return Cookies.set(key, value)
  }
}

export function removeData(DateKey) {
  if (window.sessionStorage) {
    return sessionStorage.removeItem(DateKey)
  } else {
    console.log('当前浏览器不支持Storage,启用Cookies')
    return Cookies.remove(DateKey)
  }
}
